
#ifndef		INTERPRETER_HH__
# define	INTERPRETER_HH__

# include	<map>
# include	<vector>
# include	<SFML/Graphics.hpp>
# include	"GObject.hh"
# include	"Data.hh"
# include	"Tools.hpp"

class			Interpreter
{
public:
  Interpreter(Gomoku::Data&);
  ~Interpreter(void) {}
  void			run(std::map<int, GObject*>&, int);
  int			getWpoint(void) const;
  int			getBpoint(void) const;
  void			resetPoint(void);
  bool			getWwin(void) const;
  bool			getBwin(void) const;

private:
  Gomoku::Data		&info;
  int			bpoint;
  int			wpoint;
  int			me;
  int			adv;
  bool			wwin;
  bool			bwin;

  bool			checkPos(std::map<int, GObject*>&, int, int, int);
  void			countPawn(std::map<int, GObject*>&, int, int, int, int);
  bool			inMap(int, int);
  void			checkWin5(int);

  bool			VerticalTreat(std::map<int, GObject*>&, int, int);
  bool			HorizontalTreat(std::map<int, GObject*>&, int, int);
  bool			LeftDiagonalTreat(std::map<int, GObject*>&, int, int);
  bool			RightDiagonalTreat(std::map<int, GObject*>&, int, int);

  bool			breakableHorizontal(std::map<int, GObject*>&, int, int);
  bool			breakableVertical(std::map<int, GObject*>&, int, int);
  bool			breakableLeftDiagonal(std::map<int, GObject*>&, int, int);
  bool			breakableRightDiagonal(std::map<int, GObject*>&, int, int);

  void			win5(std::map<int, GObject*>&, int, int);
  void			winHorizontal(std::map<int, GObject*>&, int, int);
  void			winVertical(std::map<int, GObject*>&, int, int);
  void			winLeftDiagonal(std::map<int, GObject*>&, int, int);
  void			winRightDiagonal(std::map<int, GObject*>&, int, int);

  void			takePawn(std::map<int, GObject*>&, int, int);
  void			checkHorizontal(std::map<int, GObject*>&, int, int);
  void			checkVertical(std::map<int, GObject*>&, int, int);
  void			checkLeftDiagonal(std::map<int, GObject*>&, int, int);
  void			checkRightDiagonal(std::map<int, GObject*>&, int, int);
};

#endif		/* !INTERPRETER */
